var fs = require('fs');
var path = require('path');
var TChannel = require('tchannel');
var HyperbahnClient = require('tchannel/hyperbahn/');
var rootChannel = TChannel();

var hyperbahnClient = HyperbahnClient({
    tchannel: rootChannel,
    serviceName: 'keyvalue-client',
    hostPortList: ['172.30.32.88:5001', '172.30.32.88:5002'],
    hardFail: true,
    reportTracing: false,
});


var keyChan = hyperbahnClient.getClientChannel({
     serviceName: 'core_order_service'
});

// console.log(keyChan);

var keyThrift = rootChannel.TChannelAsThrift({
    entryPoint: path.join(__dirname, 'thrift/core.order.thrift'),
    channel: keyChan
});


const getRepoData = (objpro) => {
  return new Promise((resolve, reject) => {
    objpro.send('CoreOrderServer::getOrderBeanById', null, {orderid:18567021297931265}, (err, body) => {
      if (err) {
        
        reject(err);
      } else {
        resolve(body);
      }
      
    });
    
  });
};

var start = async () => {
var objpro = keyThrift.request({
     // serviceName: 'core_sample_service',
     timeout: 10000,
     hasNoParent: true
});
try {
    var data = await getRepoData(objpro);
    console(data);
} catch (e) {
    console.log(e);
    }

};
start();
